<?php
/**
 * Hoffman Framework
 *
 * LICENSE
 *
 * This source file is subject to the GNU LGPL 2.1 license that is bundled
 * with this package in the file license.txt.
 * It is also available through the world-wide-web at this URL:
 * http://creativecommons.org/licenses/LGPL/2.1
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to annop@thaicyberpoint.com so we can send you a copy immediately.
 *
 * @package    Hoffman
 * @author     Ford AntiTrust
 * @copyright  Copyright (c) 2008 Ford AntiTrust (http://www.thaicyberpoint.com/ford/blog)
 * @since      Version Rv 0.2
 * @license    http://creativecommons.org/licenses/LGPL/2.1
 *             GNU LGPL 2.1
 * @filesource
 */

if (!defined('INDEX'))
    die('No direct script access allowed.');

/**
 * @see Hmf
 */
require_once 'Hmf.php';

/**
 * Hmf_View_Buffer
 *
 * @package     Hoffman
 * @subpackage  Hmf_View
 * @category    General
 * @author      Ford AntiTrust
 * @version     SVN: $Id: Buffer.php 104 2009-01-16 19:07:29Z annop.s@gmail.com $
 * @link        http://www.thaicyberpoint.com/ford/blog/hmf
 */

final class Hmf_View_Buffer extends Hmf {

    private static $buffer;
    private $viewPath;
    
    public function __construct($path, &$var) {
        
        // safe for extract from $var
        $this->viewPath = $path;
        
        if (ob_get_level() > ob_get_level() + 1)
            ob_end_flush();
        
        extract($var, EXTR_REFS);
        ob_start();
        require_once $this->viewPath;
        self::$buffer = ob_get_contents();
        ob_end_clean();
    }

    public function __toString() {

        return self::$buffer;
    }
}
?>
